<template>
  <div class="setting">
    <div class="title">
      <svg
        @click="$router.back()"
        t="1671798247143"
        class="icon"
        viewBox="0 0 1024 1024"
        version="1.1"
        xmlns="http://www.w3.org/2000/svg"
        p-id="2281"
        width="200"
        height="200"
      >
        <path
          d="M319.64 512.016l336.016-336.008 45.248 45.248L364.896 557.28z"
          p-id="2282"
        ></path>
        <path
          d="M365.216 466.464l339.976 339.968-45.256 45.256-339.976-339.976z"
          p-id="2283"
        ></path>
      </svg>
      <span>设置</span>
      <span></span>
    </div>
    <div class="action">
      <ul class="list">
        <li
          v-for="(item, index) in dataList"
          :key="index"
          @click="actionTodo(item)"
        >
          <span>{{ item }}</span>
          <img src="@/assets/imgs/向右.png" alt="" />
        </li>
      </ul>
    </div>
    <div class="safe">
      <span>账号安全</span>
      <img src="@/assets/imgs/向右.png" alt="" />
    </div>

    <div class="un-load">
      <div @click="toUnLoad">退出登录</div>
    </div>
  </div>
</template>

<script>
import Vue from "vue";
import { Toast } from "vant";
import { Dialog } from "vant";

Vue.use(Toast);
export default {
  data() {
    return {
      dataList: ["我的收藏", "我的足迹", "收货地址"],
    };
  },
  methods: {
    actionTodo(item) {
      if (item == "我的收藏") {
        this.$router.push("/myself/collection");
      } else if (item == "我的足迹") {
        this.$router.push("/myself/foot");
      } else {
        this.$router.push("/address-list");
      }
    },
    toUnLoad() {
      Dialog.confirm({
        title: "退出登录",
        message: "是否退出登录！",
      })
        .then(() => {
          localStorage.setItem("fastCar-token", "");
          Toast.success("退出成功！");
          setTimeout(() => {
            this.$router.push("/own");
          }, 1000);
        })
        .catch(() => {
          Toast.fail("取消退出！");
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.setting {
  width: 100vw;
  height: 100vh;
  background-color: rgb(245, 245, 245);
  display: flex;
  flex-direction: column;

  .title {
    display: flex;
    justify-content: space-between;
    padding: 10rem;
    background-color: #fff;
    svg {
      width: 25rem;
      height: 25rem;
    }
    span {
      font-size: 16rem;
      color: #000;
      font-weight: bold;
    }
  }

  .action {
    margin-top: 10rem;
    ul.list {
      background-color: #fff;
      padding: 0 8rem;
      li {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 14rem 0;
        border-bottom: 1px solid #eee;
        img {
          width: 25rem;
        }
        span {
          font-size: 14rem;
        }
        &:last-child {
          border-bottom: none;
        }
      }
    }
  }
  .safe {
    margin-top: 10rem;
    padding: 14rem 8rem;
    background-color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    img {
      width: 25rem;
    }
    span {
      font-size: 14rem;
    }
  }
  .un-load {
    flex-grow: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    > div {
      width: 90%;
      height: 44rem;
      border: 1rem solid #fc1c1c;
      color: #fc1c1c;
      border-radius: 22rem;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 17rem;
      margin-bottom: 40rem;
      box-sizing: border-box;
    }
  }
}
</style>